<?php
namespace app\shop\controller\driver;

use app\shop\controller\Controller;
use app\common\model\driver\Driver as DriverModel;

use think\facade\Db;

/**
 * 车辆管理
 */
class Driver extends Controller
{
    //列表
    public function index()
    {
        $model = new DriverModel;
        $data = $this->request->param();
        $list = $model->get_list($data);
        return $this->renderSuccess('', compact('list'));
    }

    public function details()
    {
        $id = $this->request->param('id');
        $model = new DriverModel;
        $info = $model->detail($id);
        return $this->renderSuccess('', compact('info'));
    }
    public function editpost()
    {
        $data = $this->request->param();
        $model = new DriverModel;
        $res = $model->where(array('driver_id'=>$data['id']))->update(array('status'=>$data['status']));
        if ($res) {
            return $this->renderSuccess('操作成功');
        }
        return $this->renderError($model->getError() ?: '操作失败');
    }

    public function delete()
    {
        $id = $this->request->param('id');
        $model = new DriverModel;
        $model->where(array('driver_id'=>$id))->delete();
        return $this->renderSuccess('操作成功');
    }

}